"""
Reference for matplotlib artists

This example displays several of matplotlib's graphics primitives (artists)
drawn using matplotlib API. A full list of artists and the documentation is
available at http://matplotlib.org/api/artist_api.html.
"""

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.path as mpath
import matplotlib.lines as mlines
import matplotlib.patches as mpatches
from matplotlib.collections import PatchCollection

def label(xy, text):
    #y = xy[1] - 0.15  # shift y-value for label so that it's below the artist
    plt.text(xy[0], xy[1], text, ha="center", family='sans-serif', size=14)

fig, ax = plt.subplots(figsize=(10,8), dpi=80)
# create 2x4 grid to plot the artists

num_x_steps = 2
num_y_steps = 4
grid = np.mgrid[0.2:0.8:(num_x_steps*1j), 0.2:0.8:(num_y_steps*1j)].reshape(2, -1).T

print grid

patches = []

# add a rectangle
rect = mpatches.Rectangle(grid[0] - [0.025, 0.05], 0.05, 0.1, fill=False, linewidth=2)
patches.append(rect)
label(grid[0], '0')

# add a rectangle
rect = mpatches.Rectangle(grid[1] - [0.025, 0.05], 0.05, 0.1, fill=False)
patches.append(rect)
label(grid[1], "1")

# add a rectangle
rect = mpatches.Rectangle(grid[2] - [0.025, 0.05], 0.05, 0.1, fill=False)
patches.append(rect)
label(grid[2], "2")

# add a rectangle
rect = mpatches.Rectangle(grid[3] - [0.025, 0.05], 0.05, 0.1, fill=False)
patches.append(rect)
label(grid[3], "3")

# add a rectangle
rect = mpatches.Rectangle(grid[4] - [0.025, 0.05], 0.05, 0.1, fill=False)
patches.append(rect)
label(grid[4], "4")

# add a rectangle
rect = mpatches.Rectangle(grid[5] - [0.025, 0.05], 0.05, 0.1, fill=False)
patches.append(rect)
label(grid[5], "5")

# add a rectangle
rect = mpatches.Rectangle(grid[6] - [0.025, 0.05], 0.05, 0.1, fill=False)
patches.append(rect)
label(grid[6], "6")


# add a rectangle
rect = mpatches.Rectangle(grid[7] - [0.025, 0.05], 0.05, 0.1, fill=False, ec="none")
patches.append(rect)
label(grid[7], "7")


for patch in patches:
	ax.add_patch(patch)

plt.subplots_adjust(left=0, right=1, bottom=0, top=1)
plt.axis('equal')
plt.axis('off')

plt.show()